package com.vmj.natives.java.lang;

import com.vmj.natives.NativeMethod;
import com.vmj.natives.Registry;
import com.vmj.rtda.Frame;

/**
 * Created by yangshoujun on 2017/9/16 下午9:47.
 */
public class Double {

    public static final java.lang.String jlClass = "java/lang/Double";

    public static void init() {
        Registry.register(jlClass, "doubleToRawLongBits", "(D)J", new NativeMethod() {
            public void execute(Frame frame) {
                double val = frame.getLocalVars().getDouble(0);
                long l = java.lang.Double.doubleToRawLongBits(val);
                frame.getOperandStack().pushLong(l);
            }
        });

        Registry.register(jlClass, "longBitsToDouble", "(J)D", new NativeMethod() {
            public void execute(Frame frame) {
                long val = frame.getLocalVars().getLong(0);
                double d = java.lang.Double.longBitsToDouble(val);
                frame.getOperandStack().pushDouble(d);
            }
        });
    }
}
